home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 11956 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.5 KB

  1. Path: rain.fr!world-net!usenet
  2. From: Frederic LACHASSE <lachass@worldnet.fr>
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: Newbie Question on using function ptr or Casting?
  5. Date: Sun, 17 Mar 1996 07:35:14 +0000
  6. Organization: World-Net information exchange, Internet provider.
  7. Message-ID: <VA.0000006b.000286c0@fred>
  8. References: <19960314170244.sstryker@sover.net>
  9. Reply-To: lachass@worldnet.fr
  10. NNTP-Posting-Host: client122.sct.fr
  11. X-Newsreader: Virtual Access by Ashmount Research Ltd, http://www.ashmount.com
  12.  
  13. Short answer: you often use in programs containers like lists, 
  14. stacks, arrays and tables to store objects. Way of handling such 
  15. containers are always the same, so it looks like a good idea to create 
  16. classes to implement container behavior that would be (mostly) 
  17. independant from the objects stored in them.
  18.  
  19. One way of building such a generic container class is to store pointers 
  20. to a simple base class. In this program, they just use the most basic of 
  21. pointers, that is void*.
  22.  
  23. This system has a drawback: you must cast back the pointer from these 
  24. containers to the original class, and it's not type safe.
  25.  
  26. The new "template" feature of C++ allow the definition of generic 
  27. type-safe containers will render the old style container classes 
  28. obsolete, the more so as the STL (Standard Template Library) will be 
  29. included in the forthcoming C++ standard and implement array, deque, 
  30. linked list, map, tree and other common containers.
  31.  
  32.  Frederic LACHASSE (ECP 86)
  33.  CompuServe: 100530,2005
  34.  Internet: lachass@worldnet.fr
  35.  
  36.